//
//  StaticTools+String.m
//  JFmerchant
//
//  Created by 文彬 on 2017/12/26.
//  Copyright © 2017年 文彬. All rights reserved.
//

#import "StaticTools+String.h"

@implementation StaticTools (String)

/*
 @abstract 校验字符串是否为空
 */
+ (BOOL)isEmptyString:(NSString *)string
{
    if (string == nil||[string isEqual:[NSNull null]])
    {
        return YES;
    }
    
    //去空格之后判断length是否为0
    NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
    NSString *content = [string stringByTrimmingCharactersInSet:whitespace];
    if ([content length] == 0)
    {
        return YES;
    }
    
    return NO;
}

/**
 *    @brief    判断一个字符串是否为整型数字
 *
 *    @param     string 源
 *
 *    @return 是否
 */
+ (BOOL) isPUreInt:(NSString*)string

{
    NSScanner *scan = [NSScanner scannerWithString:string];
    int val;
    return [scan scanInt:&val]&&[scan isAtEnd];
}

/**
 *    @brief    判断一个字符串是否为浮点型数字
 *
 *    @param     string 源
 *
 *    @return 是否
 */
+ (BOOL) isPUreFloat:(NSString*)string

{
    NSScanner *scan = [NSScanner scannerWithString:string];
    float val;
    return [scan scanFloat:&val]&&[scan isAtEnd];
}


@end
